var app = getApp()
//状态 0新发布待接单，1已接单待完成，2已完成
let orderStatus = 1;
let db = wx.cloud.database();
Page({
  data: {
    navbar: ["待完成", "已完成"],
    // 默认选中菜单
    currentTab: 0,
    list: []
  },
  //顶部tab切换
  navbarTap: function (e) {
    let index = e.currentTarget.dataset.idx;
    this.setData({
      currentTab: index
    })
    if (index == 1) {
      orderStatus = 2;
    } else {
      orderStatus = 1;
    }
    this.getMyOrderList();
  },

  onShow: function () {
    this.getMyOrderList();
  },

  getMyOrderList() {
    wx.cloud.callFunction({
        name: 'order',
        data: {
          action: 'myservice',
          status: orderStatus
        }
      })
      .then(res => {
        console.log("我的抢单列表", res)
        this.setData({
          list: res.result.data
        })
      }).catch(res => {
        console.log("我的抢单列表失败", res)
      })
  },
  makePhoneCall(e){
    console.log(e)
      wx.makePhoneCall({
        phoneNumber: e.currentTarget.dataset.phonenumber,
      })
  },
})